<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="css/bootstrap.css">
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.js"></script>
    <script src="js/sockjs.js"></script>
    <script src="js/stomp.js"></script>
    <title></title>
    <style>
        html, body {
            width: 100%;
            height: 100%;
            overflow: hidden;
            min-width: 670px !important;
            background-color: #dce8ed !important;
        }

        h3 {
            font-weight: bold;
        }

        .wrap {

        }

        .header {
            padding: 0;
            border-bottom: 1px solid darkgray;
            margin: 0 20px;
            box-sizing: border-box;
        }

        .header .col-lg-4 {
            padding: 0;
            text-align: center;
        }

        .header .logo {
            height: 100px;
            background-image: url("./img/logo.png");
            background-position: center;
            background-size: contain;
            background-repeat: no-repeat;
        }

        .header .title {
            position: relative;
            background-image: -webkit-linear-gradient(top, #eee, skyblue);
            color: #348299;
            height: 90px;
            border-bottom-left-radius: 100px;
            border-bottom-right-radius: 100px;
            overflow: hidden;
        }

        .header .title h3 {
            margin: 0;
            position: absolute;
            top: 20px;
            width: 100%;
            left: 0;
            text-align: center;
            display: inline-block;
            font-size: 50px;
            font-weight: bold;

        }

        .header .timeRight {

        }

        .header .time {
            position: relative;
            text-align: left;
            width: 300px;
            font-size: 25px;
            margin: 25px auto 0;
            background-color: #ccf3f0;
            padding: 5px;
            border: 1px solid #147e3a;
            border-radius: 10px;
            margin-bottom: 10px;
            color: #348299;
            font-weight: bold;

        }

        .header .time span {
            position: absolute;
            right: -90px;
            display: block;
            background-color: #07a09d;
            padding: 6px 5px;
            top: -1px;
            color: #f5f5f5;
            border-radius: 10px;
        }

        .header .title h1 {
            margin: 0;
            line-height: 100px;
        }

        .content {
            padding-top: 20px;
        }

        .content .latest {
            background-color: #147e3a;
            margin: 0 20px;
            border-radius: 10px;
        }

        .content .latest h3 {
            height: 30px;
            line-height: 30px;
            color: #fdffc0;
            margin: 15px 0 15px 40px;
            font-weight: bold;

        }

        .content .latest h3 span {
            width: 20px;
            height: 20px;
            background-color: white;
            border-radius: 50%;
            display: inline-block;
            box-shadow: 0 0 28px orangered inset;
            margin-right: 15px;
        }

        .content .room {
            margin: 0 20px 0;
        }

        .content .room .detailRoom {
            float: left;
        }

        .content .room .detailRoom + div {
            margin-left: 10px;
        }

        .content .detailRoom h3 {
            margin-top: 10px;
            margin-bottom: 0;
        }

        .content .room .detailRoom .title {
            text-align: center;
            font-size: 25px;
            /*background-image: -webkit-linear-gradient(top,#eee,#339999);*/
            background-color: #8ed0db;
            border-radius: 10px;

            color: #f5f5f5;
            box-shadow: 0 0 10px 1px #9d9d9d inset
        }

        .content .room .detailRoom h3 {
            background-color: #acdaec;
            text-align: center;
            border-radius: 10px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            box-shadow: 0 0 10px 1px #9d9d9d inset;
        }

        .content .room .detailRoom .index {
            margin-right: 20px;
        }

        .c02ddff {
            background: #02ddff;
        }

        .footer {
            position: fixed;
            bottom: 10px;
            width: 100%;
            background-color: #147e3a;
            min-width: 670px !important;
            margin: 0 35px;
            border-radius: 10px;

        }

        .footer-content {
            padding: 0;
        }

        .footer-content h3 {
            height: 60px;
            line-height: 60px;
            color: #fdffc0;
            margin: 0;
        }

        .footer-content h3 span {
            width: 20px;
            height: 20px;
            background-color: white;
            border-radius: 50%;
            display: inline-block;
            box-shadow: 0 0 50px orangered inset;
            margin-left: 35px;
            margin-right: 15px;
        }
    </style>
</head>
<body>
<div class="wrap">
    <div class="container-fluid header">
        <div class="col-lg-4  col-md-4 col-sm-4 col-xs-4 ">
            <div class="logo">
            </div>
        </div>
        <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 title">
            <h3 id="deptName"></h3>
        </div>
        <div class="col-lg-4  col-md-4 col-sm-4 col-xs-4 timeRight">
            <div class="time" id="year">
                <span id="hour"></span>
            </div>
        </div>
    </div>
    <div class="container-fluid content" id="content">
        <div class="row latest">
        </div>
        <div class="row room">
        </div>
    </div>
    <div class="container-fluid footer">
        <div class="footer-content">
            <h3><span></span>请其他患者在大厅候诊区耐心等待</h3>
        </div>
    </div>
</div>
<script>
    //读取客户端配置文件所得到的信息
    var data = {
        deptId: "fs",
        clientName: "fs",
        checkRoomDatas: [
            {checkId: '1', checkRoom: "放射一室"},
            {checkId: '2', checkRoom: "放射二室"},
            {checkId: '3', checkRoom: "放射三室"}
        ]
    };
    //每个科室的总呼叫数据
    var SetAllCallData = [];
    //集成每个科室的总过号数
    var SetAllPassData = [];

    //大屏每一个科室的动画的定时器开关,每一个动画开始的起始位置,每一个真正显示的数据
    var timers = [];
    var indexs = [];
    var arrShows = [];
    //保存配置文件信息
    var g_properties;

    /**
     * 捕获异常
     */
        // window.onerror = function () {
        //     alert(arguments[0]);
        //     // 阻止在控制台中打印错误信息
        //     return true;
        // };

        // 所有检查室信息
    var g_checkRoom;

    //获取检查室信息
    function getCheckData() {
        $.ajax({
            url: "/sys/checkRoom/info",
            type: "get",
            dataType: "json",
            success: function (data) {
                var str = eval(data);
                g_checkRoom = str.data;
            },
            error: function () {
                alert("获取检查室信息失败");
            }
        });
    }

    $(function () {
        // 获取所有检查室信息
        getCheckData();
    });

    /**
     * 读取配置信息
     */
    $(document).ready(function () {
        //定时执行，2秒后执行
        var t1 = window.setTimeout(refreshCount, 1000 * 0.1);

        function refreshCount() {
            // 获取配置文件信息
            getClientProperties();
            //去掉定时器
            window.clearTimeout(t1);
        }
    });

    function getClientProperties() {
        // var properties = app.getClientProperties();
        var properties = '{"clientType":"1","clientId":"86e28557-dbe7-46b4-bf5c-174c4b038a00","clientName":"放射科","deptId":"门诊部放射科","checkRoomId":"门诊部放射一室,门诊部放射二室"}';
        var _properties = eval("(" + properties + ")");
        g_properties = _properties;
        //设置大屏显示的科室
        data.deptId = g_properties.deptId;
        data.clientName = g_properties.clientName;

        var checkRooms = _properties.checkRoomId.split(",");
        // 清除数据
        data.checkRoomDatas = [];
        // 封装数据
        var _json1 = "[";
        var allCheckRooms = g_checkRoom;
        console.log(allCheckRooms);
        // 获取检查室显示名称并赋值
        for (var i = 0; i < checkRooms.length; i++) {
            for (var j = 0; j < allCheckRooms.length; j++) {
                if (checkRooms[i] == allCheckRooms[j].checkRoomId) {
                    _json1 += "{\"checkId\":\"" + checkRooms[i] + "\"," +
                        "\"checkRoom\":\"" + allCheckRooms[j].checkRoomDisplayName + "\"},";
                }
            }
            // _json1 += "{\"checkId\":\""+checkRooms[i]+"\",\"checkRoom\":\""+checkRooms[i]+"\"},";
        }
        _json1 += "]";
        data.checkRoomDatas = eval("(" + _json1 + ")");

        //对大屏的数据做格式化处理
        data.checkRoomDatas.forEach(function (item) {
            item.dataAll = {};
            //展示(未呼)数据
            item.dataAll.showData = [];
            //已呼数据
            item.dataAll.callData = [];
            //过号数据
            item.dataAll.guoData = [];
            //总的数据(包括:未呼，已呼，过号)
            item.zongData = [];
        });
        //对大屏的数据显示的工具赋初始值
        data.checkRoomDatas.forEach(function (item, index) {
            timers[index] = null;
            indexs[index] = 0;
            arrShows[index] = [];
        });

        console.log("data init end ")
        console.log(data)


        //创建相应的科室的列数
        var createLength = data.checkRoomDatas.length;
        for (var i = 0; i < createLength; i++) {
            var checkRoom = "<div class='detailRoom'><h3 class='title'>" +
                data.checkRoomDatas[i].checkRoom + "</h3><div  class='detailPerson'></div></div>";
            $(".room").append(checkRoom);
        }
        //创建的列数平均分配宽度
        settingWidth();
        // 获取数据
        getSomeData();
        //显示科室名称
        $("#deptName").html(data.clientName);

        initWebSocket();

    }


    function getSomeData() {
        //重启客服端获得以前的数据
        $.ajax({
            url: "/queue/cacheDept?deptId=" + data.deptId,
            // url: "http://192.168.2.106:8080/queue/cacheDept?deptId=" + data.deptId,
            method: "GET",
            success: function (res) {
                //重启客户端之后从后台获取以前的信息,并封装成相应的数据格式
                data.checkRoomDatas.forEach(function (item1, index) {
                    res.data.forEach(function (item2, index1) {
                        if (item2.checkRoom === item1.checkRoom) {
                            item2.queueDtoList.forEach(function (item3) {
                                //获取为呼叫数据
                                if (item3.checkStatus === 0) {
                                    item1.dataAll.showData.push(item3);
                                }
                                //获取过号数据
                                if (item3.checkStatus === 1) {
                                    //过号放入全局过号数据集合
                                    SetAllPassData.push(item3);
                                    bottomShow();
                                    item1.dataAll.guoData.push(item3)
                                }
                                // else if (item3.checkStatus === 3) {
                                //     item1.dataAll.callData.push(item3)
                                // }
                            })
                        }
                    });
                    //集成每一个诊室的总数据
                    SetAllData(item1);
                    //操作显示页面
                    showDataTal(index);
                });

            }
        });
    }

    //平均分配每一个诊室列的宽度
    function settingWidth() {
        var length = $(".detailRoom").length;
        var widthAll = $(".room").width();
        var width = (widthAll - (length - 1) * 10) / length;
        $.each($(".detailRoom"), function (index, item) {
            $(item).css("width", width + "px");
        });
    }

    //每一个科室默认显示10行数据
    $.each($(".detailPerson"), function (index, item) {
        for (var i = 0; i < 10; i++) {
            var h3 = "<h3></h3>";
            $(item).append(h3)
        }
    });
    //显示时间
    setInterval(function () {
        var time = new Date();
        var year = time.getFullYear();
        var month = parseInt(time.getMonth()) + 1;
        month = month < 10 ? '0' + month : month;
        var date = time.getDate();
        date = date < 10 ? '0' + date : date;
        var hour = time.getHours();
        hour = hour < 10 ? '0' + hour : hour;
        var second = time.getSeconds();
        second = second < 10 ? '0' + second : second;
        var minute = time.getMinutes();
        minute = minute < 10 ? '0' + minute : minute;
        var day = this.showDay(parseInt(time.getDay()));

        $("#year").html(year + '年' + month + '月' + date + '日' + ' ' + day);
        $("#year").html($("#year").html() + "<span>" + hour + ':' + minute + ':' + second + "</span>")
    }, 1000);

    function showDay(week) {
        if (week === 0) {
            return "星期天";
        } else if (week === 1) {
            return "星期一";
        } else if (week === 2) {
            return "星期二";
        } else if (week === 3) {
            return "星期三";
        } else if (week === 4) {
            return "星期四";
        } else if (week === 5) {
            return "星期五";
        } else if (week === 6) {
            return "星期六";
        }
    }

    //调整高度
    resizeHeight();

    function resizeHeight() {
        var screenHeight = document.body.clientHeight || document.documentElement.clientHeight;
        screenHeight = screenHeight - 370;
        var contentHeight = (screenHeight) / 11;
        $(".detailRoom h3").css('height', contentHeight + "px").css("fontSize", contentHeight * .7 + "px").css("lineHeight", contentHeight + "px");
    }

    window.onresize = function () {
        resizeHeight();
        settingWidth();
    };

    //sockJs操作
    var stompClient;
    var socket;
    //sickJs重连定时器
    var timer;

    function initWebSocket() {
        connection();
    }

    function connection() {

        // 建立连接对象
        socket = new SockJS('/zd-queuing-websocket');
        // socket = new SockJS('http://192.168.2.106:8080/zd-queuing-websocket');
        // var socket = new SockJS('/zd-queuing-websocket');
        // 获取STOMP子协议的客户端对象
        stompClient = Stomp.over(socket);
        // // 定义客户端的认证信息,按需求配置
        // var showData = [];
        //http://192.168.2.106:8080/zd-queuing-websocket
        // 向服务器发起websocket连接
        stompClient.connect({},
            function () {
                stompClient.subscribe('/call/dept/' + data.deptId, function (msg) { // 订阅服务端提供的呼叫
                    var queueId = msg.body;

                    data.checkRoomDatas.forEach((function (item1, index1) {
                        item1.dataAll.showData.forEach(function (item2, index2) {
                            if (queueId === item2.queueId) {
                                SetAllCallData.push(item2);
                                item1.dataAll.callData.push(item2);
                                //呼叫集合去重
                                fnSetAllCallData(item1);
                                // console.log(item1.dataAll.callData);
                                // item1.dataAll.showData.splice(index2, 1);
                                //操作显示页面
                                showDataTal(index1);
                                SetAllData(item1);
                            }
                        })
                    }));
                    //处理从过号队列选择呼号导致大屏不显示的bug
                    SetAllPassData.forEach(function (item) {
                        if (item.queueId === queueId) {
                            SetAllCallData.push(item);
                            fnSetAllCallData('');
                        }
                    });
                    topShow();
                });
                stompClient.subscribe('/finish/dept/' + data.deptId, function (msg) { // 订阅服务端提供的就诊完毕
                    var queueId = msg.body;
                    SetAllCallData.forEach(function (item, index) {
                        if (item.queueId === queueId
                        ) {
                            SetAllCallData.splice(index, 1)
                        }
                    });
                    data.checkRoomDatas.forEach((function (item1, index1) {
                        item1.dataAll.showData.forEach(function (item2, index2) {
                            if (queueId === item2.queueId) {
                                item1.dataAll.showData.splice(index2, 1);
                                showDataTal(index1);
                                SetAllData(item1);
                            }
                        })
                    }));
                    SetAllPassData.forEach(function (item, index) {
                        if (item.queueId === queueId
                        ) {
                            SetAllPassData.splice(index, 1)
                        }
                    })
                });
                stompClient.subscribe('/pass/dept/' + data.deptId, function (msg) { // 订阅服务端提供的过号
                    var queueId = msg.body;
                    data.checkRoomDatas.forEach((function (item1, index1) {
                        item1.dataAll.showData.forEach(function (item2, index2) {
                            if (queueId === item2.queueId) {
                                SetAllPassData.push(item2);
                                item1.dataAll.showData.splice(index2, 1);
                                showDataTal(index1);
                                SetAllData(item1);
                            }
                        })
                    }));
                    bottomShow();
                });
                stompClient.subscribe('/newPatient/dept/' + data.deptId, function (msg) {
                    var res = JSON.parse(msg.body);
                    data.checkRoomDatas.forEach(function (item1, index) {
                        res.forEach(function (item2, index1) {
                            if (item2.checkRoom === item1.checkRoom) {
                                var showData = item1.dataAll.showData;
                                if (showData.length === 0) {
                                    showData = res[index1].queueDtoList;
                                    var ceil = Math.ceil(showData.length / 10);
                                    while (showData.length < ceil * 10) {
                                        showData.push({
                                            "queueId": "",
                                            "patientName": "",
                                            "patientSex": "",
                                            "patientAge": "",
                                            "inspectId": "",
                                            "imageNumber": "",
                                            "department": "",
                                            "departmentId": "",
                                            "checkRoom": "",
                                            "checkId": "",
                                            "checkRoomDisplayName": "",
                                            "waitPatientNumber": "",
                                            "className": "",
                                            "cliisinpat": "",
                                            "checkInTime": "",
                                            "checkStatus": "",
                                            "confirmTime": ""
                                        })
                                    }
                                }
                                else {
                                    var ceil1 = Math.ceil(res[index1].queueDtoList.length / 10);
                                    while (res[index1].queueDtoList.length < ceil1 * 10) {
                                        res[index1].queueDtoList.push({
                                            "queueId": "",
                                            "patientName": "",
                                            "patientSex": "",
                                            "patientAge": "",
                                            "inspectId": "",
                                            "imageNumber": "",
                                            "department": "",
                                            "departmentId": "",
                                            "checkRoom": "",
                                            "checkId": "",
                                            "checkRoomDisplayName": "",
                                            "waitPatientNumber": "",
                                            "className": "",
                                            "cliisinpat": "",
                                            "checkInTime": "",
                                            "checkStatus": "",
                                            "confirmTime": ""
                                        })
                                    }
                                    var data1 = [];
                                    showData.forEach(function (item) {
                                        data1.push(item);
                                    });
                                    res[index1].queueDtoList.forEach(function (item) {
                                        data1.push(item);
                                    });
                                    showData = data1;
                                    item1.dataAll.showData = showData;
                                }
                            }
                        });
                        //集成每一个诊室的总数据
                        SetAllData(item1);
                        //操作显示页面
                        showDataTal(index);
                    });
                })
            },
            function (err) {
                timer = setInterval(function () {
                    // 建立连接对象
                    // socket = new SockJS('http://192.168.2.106:8080/zd-queuing-websocket');
                    socket = new SockJS('/zd-queuing-websocket');
                    // var socket = new SockJS('/zd-queuing-websocket');
                    // 获取STOMP子协议的客户端对象
                    stompClient = Stomp.over(socket);
                    stompClient.connect({},
                        //成功回调
                        function () {
                            stompClient.subscribe('/call/dept/' + data.deptId, function (msg) { // 订阅服务端提供的呼叫
                                var queueId = msg.body;

                                data.checkRoomDatas.forEach((function (item1, index1) {
                                    item1.dataAll.showData.forEach(function (item2, index2) {
                                        if (queueId === item2.queueId) {
                                            SetAllCallData.push(item2);
                                            item1.dataAll.callData.push(item2);
                                            //呼叫集合去重
                                            fnSetAllCallData(item1);
                                            // console.log(item1.dataAll.callData);
                                            // item1.dataAll.showData.splice(index2, 1);
                                            //操作显示页面
                                            showDataTal(index1);
                                            SetAllData(item1);
                                        }
                                    })
                                }));
                                //处理从过号队列选择呼号导致大屏不显示的bug
                                SetAllPassData.forEach(function (item) {
                                    if (item.queueId === queueId) {
                                        SetAllCallData.push(item);
                                        fnSetAllCallData('');
                                    }
                                });
                                topShow();
                            });
                            stompClient.subscribe('/finish/dept/' + data.deptId, function (msg) { // 订阅服务端提供的就诊完毕
                                var queueId = msg.body;
                                SetAllCallData.forEach(function (item, index) {
                                    if (item.queueId === queueId
                                    ) {
                                        SetAllCallData.splice(index, 1)
                                    }
                                });
                                data.checkRoomDatas.forEach((function (item1, index1) {
                                    item1.dataAll.showData.forEach(function (item2, index2) {
                                        if (queueId === item2.queueId) {
                                            item1.dataAll.showData.splice(index2, 1);
                                            showDataTal(index1);
                                            SetAllData(item1);
                                        }
                                    })
                                }));
                                SetAllPassData.forEach(function (item, index) {
                                    if (item.queueId === queueId
                                    ) {
                                        SetAllPassData.splice(index, 1)
                                    }
                                })
                            });
                            stompClient.subscribe('/pass/dept/' + data.deptId, function (msg) { // 订阅服务端提供的过号
                                var queueId = msg.body;
                                data.checkRoomDatas.forEach((function (item1, index1) {
                                    item1.dataAll.showData.forEach(function (item2, index2) {
                                        if (queueId === item2.queueId) {
                                            SetAllPassData.push(item2);
                                            item1.dataAll.showData.splice(index2, 1);
                                            showDataTal(index1);
                                            SetAllData(item1);
                                        }
                                    })
                                }));
                                bottomShow();
                            });
                            stompClient.subscribe('/newPatient/dept/' + data.deptId, function (msg) {
                                var res = JSON.parse(msg.body);
                                data.checkRoomDatas.forEach(function (item1, index) {
                                    res.forEach(function (item2, index1) {
                                        if (item2.checkRoom === item1.checkRoom) {
                                            var showData = item1.dataAll.showData;
                                            if (showData.length === 0) {
                                                showData = res[index1].queueDtoList;
                                                var ceil = Math.ceil(showData.length / 10);
                                                while (showData.length < ceil * 10) {
                                                    showData.push({
                                                        "queueId": "",
                                                        "patientName": "",
                                                        "patientSex": "",
                                                        "patientAge": "",
                                                        "inspectId": "",
                                                        "imageNumber": "",
                                                        "department": "",
                                                        "departmentId": "",
                                                        "checkRoom": "",
                                                        "checkId": "",
                                                        "checkRoomDisplayName": "",
                                                        "waitPatientNumber": "",
                                                        "className": "",
                                                        "cliisinpat": "",
                                                        "checkInTime": "",
                                                        "checkStatus": "",
                                                        "confirmTime": ""
                                                    })
                                                }
                                            }
                                            else {
                                                var ceil1 = Math.ceil(res[index1].queueDtoList.length / 10);
                                                while (res[index1].queueDtoList.length < ceil1 * 10) {
                                                    res[index1].queueDtoList.push({
                                                        "queueId": "",
                                                        "patientName": "",
                                                        "patientSex": "",
                                                        "patientAge": "",
                                                        "inspectId": "",
                                                        "imageNumber": "",
                                                        "department": "",
                                                        "departmentId": "",
                                                        "checkRoom": "",
                                                        "checkId": "",
                                                        "checkRoomDisplayName": "",
                                                        "waitPatientNumber": "",
                                                        "className": "",
                                                        "cliisinpat": "",
                                                        "checkInTime": "",
                                                        "checkStatus": "",
                                                        "confirmTime": ""
                                                    })
                                                }
                                                var data1 = [];
                                                showData.forEach(function (item) {
                                                    data1.push(item);
                                                });
                                                res[index1].queueDtoList.forEach(function (item) {
                                                    data1.push(item);
                                                });
                                                showData = data1;
                                                item1.dataAll.showData = showData;
                                            }
                                        }
                                    });
                                    //集成每一个诊室的总数据
                                    SetAllData(item1);
                                    //操作显示页面
                                    showDataTal(index);
                                });
                            });
                            if (null != timer && undefined != timer) {
                                window.clearInterval(timer);
                                //递归调用
                                connection();
                            }
                        }
                    );

                }, 2000)
            }
        );
    }

    //连接 后台

    window.onunload = function () {
        disconnect();
    };

    function disconnect() {
        if (stompClient) {
            stompClient.disconnect();
        }
    } // 断开连接

    //具体数据显示函数
    function showDataTal(index) {
        var showData = data.checkRoomDatas[index].dataAll.showData;
        var youzhi = [];
        var meizhi = [];
        showData.forEach(function (item) {
            if (!item.checkId) {
                meizhi.push(item)
            }
            else youzhi.push(item)
        });
        var data2 = [];
        youzhi.forEach(function (item) {
            data2.push(item);
        });
        showData = data2;
        data.checkRoomDatas[index].dataAll.showData = showData;
        clearInterval(timers[index]);
        var ceil3 = Math.ceil(showData.length / 10);
        while (showData.length < ceil3 * 10) {
            showData.push({
                "queueId": "",
                "patientName": "",
                "patientSex": "",
                "patientAge": "",
                "inspectId": "",
                "imageNumber": "",
                "department": "",
                "departmentId": "",
                "checkRoom": "",
                "checkId": "",
                "checkRoomDisplayName": "",
                "waitPatientNumber": "",
                "className": "",
                "cliisinpat": "",
                "checkInTime": "",
                "checkStatus": "",
                "confirmTime": ""
            })
        }
        timers[index] = setInterval(function () {
            dataShow(index)
        }, 5000);
        dataShow(index);

        function dataShow(index) {

            var ceilAll = Math.ceil(showData.length / 10);
            if (indexs[index] < ceilAll) {
                arrShows[index] = showData.slice(indexs[index] * 10, indexs[index] * 10 + 10);
                indexs[index]++;
            }
            else {
                indexs[index] = 0;
            }
            $(".detailPerson").eq(index).html('');
            for (var i = 0; i < arrShows[index].length; i++) {

                var h3 = "<h3>" + arrShows[index][i].queueId + " " + arrShows[index][i].patientName + "</h3>";

                $(".detailPerson").eq(index).html($(".detailPerson").eq(index).html() + h3);
                resizeHeight();
            }
        }
    }

    //集成每一个诊室的总数据
    function SetAllData(dataList) {
        dataList.dataAll.showData.forEach(function (item) {
            dataList.zongData.push(item)
        });
        dataList.dataAll.callData.forEach(function (item) {
            dataList.zongData.push(item)
        });
        dataList.dataAll.guoData.forEach(function (item) {
            dataList.zongData.push(item)
        });
        //去重操作
        var result = [];
        var obj = {};
        for (var i = 0; i < dataList.zongData.length; i++) {
            if (!obj[dataList.zongData[i].queueId]) {
                result.push(dataList.zongData[i]);
                obj[dataList.zongData[i].queueId] = true;
            }
        }
        dataList.zongData = result;
    }

    //底部数据循环显示
    //设置底部动画显示的开关
    var bottomTimer = null;
    //底部动画的初始显示值
    var bottomIndex = 0;
    bottomShow();

    function bottomShow() {
        if (SetAllPassData.length > 0) {
            if (bottomIndex >= SetAllPassData.length) {
                bottomIndex = 0;
            }
            $('.footer-content h3').html("<h3><span></span>当前过号信息: " + SetAllPassData[bottomIndex].queueId + ' ' + SetAllPassData[bottomIndex].patientName + "</h3>");
            bottomIndex++;
        }
        else {
            var html = "<h3><span></span>请其他患者在大厅候诊区耐心等待</h3>";
            $('.footer-content h3').html(html);
        }
        clearInterval(bottomTimer);
        bottomTimer = setInterval(function () {
            if (SetAllPassData.length > 0) {

                if (bottomIndex >= SetAllPassData.length) {
                    bottomIndex = 0;
                }
                $('.footer-content h3').html("<h3><span></span>当前过号信息: " + SetAllPassData[bottomIndex].queueId + ' ' + SetAllPassData[bottomIndex].patientName + "</h3>");
                bottomIndex++;
            }
            else {
                var html = "<h3><span></span>请其他患者在大厅候诊区耐心等待</h3>";
                $('.footer-content h3').html(html);
            }
        }, 3000);
    }

    //顶部数据循环显示
    //设置顶部动画显示的开关
    var topTimer = null;
    //顶部动画的初始显示值
    var topIndex = 0;
    topShow();

    function topShow() {
        if (SetAllCallData.length > 0) {
            if (topIndex >= SetAllCallData.length) {
                topIndex = 0;
            }
            $('.latest').html("<h3><span></span>请" + SetAllCallData[topIndex].queueId + ' ' + SetAllCallData[topIndex].patientName + '到' + SetAllCallData[topIndex].checkRoom + '就诊' + "</h3>");
            topIndex++;
        }
        else {
            var html = "<h3><span></span>暂无呼号信息,请耐心等待</h3>";
            $('.latest').html(html);
        }
        clearInterval(topTimer);
        topTimer = setInterval(function () {
            if (SetAllCallData.length > 0) {
                if (topIndex >= SetAllCallData.length) {
                    topIndex = 0;
                }
                $('.latest').html("<h3><span></span>请" + SetAllCallData[topIndex].queueId + ' ' + SetAllCallData[topIndex].patientName + '到' + SetAllCallData[topIndex].checkRoom + '就诊' + "</h3>");
                topIndex++;
            }
            else {
                var html = "<h3><span></span>暂无呼号信息,请耐心等待</h3>";
                $('.latest').html(html);
            }
        }, 3000);
    }

    //呼叫集合去重
    function fnSetAllCallData(item1) {
        //去重操作
        var result = [];
        var obj = {};
        for (var i = 0; i < SetAllCallData.length; i++) {
            if (!obj[SetAllCallData[i].queueId]) {
                result.push(SetAllCallData[i]);
                obj[SetAllCallData[i].queueId] = true;
            }
        }
        SetAllCallData = result;
        if (item1) {
            var result1 = [];
            var obj1 = {};
            for (var j = 0; j < item1.dataAll.callData.length; j++) {
                if (!obj1[item1.dataAll.callData[j].queueId]) {
                    result1.push(item1.dataAll.callData[j]);
                    obj1[item1.dataAll.callData[j].queueId] = true;
                }
            }
            item1.dataAll.callData = result1;
        }
    }
</script>
</body>
</html>